#pragma warning( disable: 4786 )
#include <vector>

#include "diamonddozenguts.h"

class SubInfo
{
	public:
		uint8 m_reel;
		uint8 m_position;
		uint8 m_multiplier;
		SubInfo(uint8 reel, uint8 position)
		{
			m_reel = reel;
			m_position = position;
			m_multiplier = 0;
		}
};

typedef vector<SubInfo> SubList;

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::DiamondDozenGuts()
///
/// This is the default constructor for the class.
////////////////////////////////////////////////////////////////////////////
DiamondDozenGuts::DiamondDozenGuts()
{
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::classifyStops()
///
/// @param   stops      The array of stop positions for the line.
/// @param   bet        The value of the line bet.
/// @param   line       The index of the line.
///
/// @return	 uint8      A payout from the SpinResult enumeration as a uint8.
///
/// This helper method is used to calculate the payout on a line.
////////////////////////////////////////////////////////////////////////////
void
DiamondDozenGuts::classifyStops(SpinLine* spinline, uint8* stops,uint8 bet, uint8 line, uint8& rtnresult, uint8& multiplier)
{
	SpinResult result				= EVT_LOSER;	// spin result :)
	uint8	   testIcon				= BLANK;		// Icon at current position
	uint8	   iconNotSubstitute	= BLANK;		// Holder for an Icon that is NOT a diamond
	uint8	   substCount			= 0;			// Has a WILD icon (a cleopatra icon) in the sequence
	uint8	   streakCount			= 0;
    bool8	   bFirstIconSubstitute	= false;		// White Diamond in the first spot means it can stand alone OR substitute
	bool8	   diamondsubstitute	= false;

    // By default everything pays at a x1 multiplier
    multiplier = 1;

	//Now, go through the rest, until the streak is over
 	for ( uint8 i = 0; (i < getReelCount()); i++ )
    {
		testIcon = getIcon(getGameModeId(), i, stops[i])->iconid;

        // Check to see if it is substitution (we bump the count and continue looking)
        if ( testIcon == WHITEDIAMOND )
        {
            if ( i == 0 )
            {
                bFirstIconSubstitute = true;
				diamondsubstitute = true;
				streakCount = 1;
            }
			else if (streakCount == i)
			{
				++streakCount;
			}
			substCount++;
        }
        // Blue Diamonds don't pay on individual lines,
        // just as scatters.
        else if ( testIcon == BLUEDIAMOND )
        {
            break;
        }
        else
        {
            // If we haven't found our first non diamond icon, store it off.
            if ( iconNotSubstitute == BLANK )
            {
                iconNotSubstitute = testIcon;
            }
            // If we have found our fist non cleo icon, and this icon was not cleo
            // or pyramid (those were checked above) and it is not the same as
            // the first non cleo icon, then our evaluation stops.
            else if ( iconNotSubstitute != testIcon )
            {
                break;
            }
        }
    }

	//All other Icons EVAL
	switch(iconNotSubstitute)
	{

		case MAN:
			if ( i == 5 )
			{
                result = EVT_FIVE_MAN;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_MAN;
			}
			else if (i == 3)
            {
                result = EVT_THREE_MAN;
			}
			else if (i == 2)
            {
                result = EVT_TWO_MAN;
			}
			break;

		case WOMAN:
			if ( i == 5 )
			{
                result = EVT_FIVE_WOMAN;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_WOMAN;
			}
			else if (i == 3)
            {
                result = EVT_THREE_WOMAN;
			}
			else if (i == 2)
            {
                result = EVT_TWO_WOMAN;
			}
			break;

		case RING:
			if ( i == 5 )
			{
                result = EVT_FIVE_RING;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_RING;
			}
			else if (i == 3)
            {
                result = EVT_THREE_RING;
			}
			else if (i == 2)
            {
                result = EVT_TWO_RING;
			}
			break;

		case PURSE:
			if ( i == 5 )
			{
                result = EVT_FIVE_PURSE;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_PURSE;
			}
			else if (i == 3)
            {
                result = EVT_THREE_PURSE;
			}
			break;

		case ROSE:
			if ( i == 5 )
			{
                result = EVT_FIVE_ROSE;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_ROSE;
			}
			else if (i == 3)
            {
                result = EVT_THREE_ROSE;
			}
			break;

        case ACE:
			if ( i == 5 )
			{
                result = EVT_FIVE_ACE;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_ACE;
			}
			else if (i == 3)
            {
                result = EVT_THREE_ACE;
			}
			break;

        case KING:
			if ( i == 5 )
			{
                result = EVT_FIVE_KING;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_KING;
			}
			else if (i == 3)
            {
                result = EVT_THREE_KING;
			}
            break;

        case QUEEN:
			if ( i == 5 )
			{
                result = EVT_FIVE_QUEEN;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_QUEEN;
			}
			else if (i == 3)
            {
                result = EVT_THREE_QUEEN;
			}
			break;

        case JACK:
			if ( i == 5 )
			{
                result = EVT_FIVE_JACK;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_JACK;
			}
			else if (i == 3)
            {
                result = EVT_THREE_JACK;
			}
			break;

        case TEN:
			if ( i == 5 )
			{
                result = EVT_FIVE_TEN;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_TEN;
			}
			else if (i == 3)
            {
                result = EVT_THREE_TEN;
			}
			break;

        case NINE:
			if ( i == 5 )
			{
                result = EVT_FIVE_NINE;
			}
			else if (i == 4)
            {
                result = EVT_FOUR_NINE;
			}
			else if (i == 3)
            {
                result = EVT_THREE_NINE;
			}
			break;

        // Coin and Blanks don't pay.
        case BLUEDIAMOND:
        case BLANK:
            break;

        // Some unknown symbol is on the reel!
        default:
            ASSERT(false);
            break;
	}

    // Now, if the player started with White Diamond
    // and ended with some other symbol, then
    // it is possible the diamonds are worth more 
    // by themselves then they are in combination
    // with another symbol.  Check to see
    // if that is the case and if so, alter the result.
    if ( substCount >= 1 && bFirstIconSubstitute )
    {
        SpinResult diamondResult = EVT_LOSER;

	    if(streakCount == 5 )
	    {
		    diamondResult = EVT_FIVE_WHITEDIAMOND;
	    }
	    else if (streakCount == 4)
	    {
		    diamondResult = EVT_FOUR_WHITEDIAMOND;
	    }
	    else if (streakCount == 3)
	    {
		    diamondResult = EVT_THREE_WHITEDIAMOND;
	    }
	    else if (streakCount == 2)
	    {
		    diamondResult = EVT_TWO_WHITEDIAMOND;
	    }
	    else if (streakCount == 1)
	    {
		    diamondResult = EVT_ONE_WHITEDIAMOND;
	    }

        if ( getPayout(diamondResult)->payoutAmount > getPayout(result)->payoutAmount )
        {
            result = diamondResult;
            multiplier = 1;
			diamondsubstitute = false;
        }
    }

	if (result > EVT_LOSER && substCount && diamondsubstitute)
	{
        spinline->addNote(NOTE_WHITEDIAMOND_SUBSTITUTION);
	}

    rtnresult = (uint8) result;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::classifyScatters()
///
/// @param   spin       Pointer to the spin with stop data.
///
/// This is an override of the framework method.
/// It determines if the current spin merits free spins or scatter payments.
////////////////////////////////////////////////////////////////////////////
void
DiamondDozenGuts::classifyScatters(SlotSpin *spin)
{
    int32   whiteScatterPositions	= 0;
	uint8   numBlueScatterIcons		= 0;
    int32   blueScatterPositions	= 0;
	uint8   stop					= 0;
	uint8   whichItem				= BLANK;
    uint8   position				= 0;
    uint8   multiplier				= ( getGameModeId() == MODE_FREE_SPIN )  ? MULTIPLIER_FREE_SPIN : 1;
	SubList list;

	spin->clearScatters();

	// If we are in the first paid spin (NOT a bonus spin) try for the Random Progressive Jackpot
	if (getGameModeId() == MODE_NORMAL )
	{
		if ( getRandomProgressiveJackpotResult(spin->getSpinLineCount()) ||
			 m_bForceRandomJackpot)
        {
	        spin->addScatter( 0,
                              getPayout(EVT_RANDOM_PROGRESSIVE_WINNER)->payoutAmount,
                              1,
                              true,
                              EVT_RANDOM_PROGRESSIVE_WINNER,
                              0 );
        }
    }

	// We are evaluating all positions on each
	// reel before checking the next reel to help
	// short circuit logic for determining left
	// to right scatters.
  	for (int reel = 0; reel<5; reel++)
	{
    	for (int row = 0; row < 3; row++)
		{
			// Even though we are evaluating every row within every
			// reel, the client side code expects the scatter position mask
			// to be every reel for within each row.  Given this, instead
			// of incrementing the position each time through the loop
			// we calculate it.
            position = (row*5)+reel;
			
			stop = relativeWheelPosition(getGameModeId(), reel, spin->getStops()[reel], row);
			whichItem = getIcon(getGameModeId(), reel, stop)->iconid;

			if (whichItem == WHITEDIAMOND)
			{
				SubInfo subi(reel,row);
				list.push_back(subi);
				whiteScatterPositions += 1 << position;
			}
			else if (whichItem == BLUEDIAMOND)
			{
				// This little check ensures we only count
				// blue diamonds left to right.
				if ( numBlueScatterIcons == reel )
				{
					numBlueScatterIcons++;
					blueScatterPositions += 1<<position;
				}
            }

		} // row
	} // reel

	// If we have at least one blue diamond, then we have 
	// either had a near miss or we have won a scatter
	// prize and/or free games.  Because of how we
	// evaluated the rows, only left to right blue diamonds
	// are part of this count.
	if (numBlueScatterIcons >= 1 )
    {
        uint8 payouttypeid = EVT_SCATTER_NEAR_MISS;

	    switch ( numBlueScatterIcons )
	    {
           case 2:
				payouttypeid = EVT_TWO_BLUEDIAMOND;
                break;
	       case 3:
	            payouttypeid = EVT_THREE_BLUEDIAMOND;
                break;
	       case 4:
	            payouttypeid = EVT_FOUR_BLUEDIAMOND;
                break;
           case 5:
                payouttypeid = EVT_FIVE_BLUEDIAMOND;
                break;
	    };

        int32 nPayout = getPayout(payouttypeid)->payoutAmount * ( spin->getSpinLineCount());
		increaseTotalWin(nPayout*multiplier);

		// Handle the blue diamond scatter prize award.  This will 
		// also report the scatter near miss if there were not enough 
		// diamonds.
	    SlotScatter* pScatter = spin->addScatter( blueScatterPositions,
                                                  nPayout*getBetPerLine(),
                                                  multiplier,
                                                  false,
                                                  payouttypeid,
                                                  0 );

		// Add the note if this occurred during free spins.
		if ( getGameModeId() == MODE_FREE_SPIN )
		{
			pScatter->addNote(NOTE_FREE_SPIN_2X);
		}

		// If there are 3 or more blue icons left to right we have won free games.
		if ( numBlueScatterIcons >= 3 )
		{
			spin->addScatter(blueScatterPositions, 0, 0, false, EVT_FREE_GAMES, FREE_SPINS);
			incrementFreeSpins(FREE_SPINS);
			setGameModeId(MODE_FREE_SPIN);
		}
    }

	// Lets check for Diamond Delight
	// If there was at least one white diamond in the list, we
	// need to process this.
	if (list.size() > 0)
    {
		// The feature was triggered if there were three or more diamonds.
		bool8 bFeatureTriggered = (list.size() >= 3);

		if ( bFeatureTriggered )
		{
			SubList::iterator   sit = list.begin();
			SubInfo*			info = NULL;
			int32				mask = 0;

			InitDiamondDelight();

			// Walk the list and initialize the diamond mulipliers,
			// and set the reel mask.
			while (sit != list.end())
			{
				info = &*sit;
				DEBUGMSG(("Reel: %d, position: %d", info->m_reel, info->m_position));
				info->m_multiplier = getDiamondDelightMultiplier();
				mask |= (1<<(info->m_reel));
				setFDDiamondMultiplier(info->m_reel, info->m_multiplier);
				++sit;
			}

			// Update subgame data in preparation to play.
			m_subGame->update(SGDINDX_DIAMOND_MASK, mask);
			m_subGame->update(SGDINDX_DIAMOND_COUNT, list.size());
			m_subGame->update(SGDINDX_PICK_COUNT, 0);
			m_subGame->update(SGDINDX_DDELUX_ACTIVE, 1);

			setGameCanComplete(false);

			// Add the scatter record that shows they triggered the feature.
			spin->addScatter(whiteScatterPositions, 0, 0, false, EVT_DIAMONDDELIGHT, 0);
		}
		else
		{
			// Otherwise they had only 1 or 2 white diamond.  Near miss.
			DEBUGMSG(("Diamond Delight near miss"));
			spin->addScatter(whiteScatterPositions, 0, 0, false, EVT_FEATURE_NEAR_MISS, 0);
		}

		list.clear();
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::isValidGuts()
///
/// @return	 bool8      True if gut is valid.
///
/// This helper method is used to the current gut ID is valid.
////////////////////////////////////////////////////////////////////////////
bool8
DiamondDozenGuts::isValidGuts()
{
    return (getGutsId() >= 600 && getGutsId() < 700);
}

bool8
DiamondDozenGuts::hasSavedGames()
{
	return true;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::getGameModeMultiplierAndNoteId()
///
/// @param   nGameModeMultiplier
/// @param   nNoteId
///
/// @return	 void
///
/// This helper method is used to the current gut ID is valid.
////////////////////////////////////////////////////////////////////////////
void
DiamondDozenGuts::getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId )
{
    if ( getGameModeId() == MODE_FREE_SPIN )
    {
        nGameModeMultiplier = MULTIPLIER_FREE_SPIN;
        nNoteId = NOTE_FREE_SPIN_2X;
    }
    else
    {
        SlotGuts::getGameModeMultiplierAndNoteId( nGameModeMultiplier, nNoteId );
    }

}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::processClientData()
///
/// @return	 void
///
///
/// This is an override of the framework method.  Was playBonusGame but was
/// changed to be more generic.
/// 
////////////////////////////////////////////////////////////////////////////
bool8
DiamondDozenGuts::processClientData(uint8 dataType, int32 dataCount, int32 *data)
{
	// Start by assuming that we do not need to reply to this message
	bool8 bReply = false;

	if (dataType == 1 && dataCount == 1 && (*data >= 0 && *data < 5))
	{
		int32 diamondCount = m_subGame->getData(SGDINDX_DIAMOND_COUNT);
		int32 pickCount = m_subGame->getData(SGDINDX_PICK_COUNT);
		int32 diamondMask = m_subGame->getData(SGDINDX_DIAMOND_MASK);
		int32 active = m_subGame->getData(SGDINDX_DDELUX_ACTIVE);
		
		// Check to see if we should be playing
		if (diamondCount > 0 && pickCount <= diamondCount && diamondMask && active == 1)
		{
			int32 diamond = *data;

			// Have we selected a valid diamond
			if (diamondMask & (1<<diamond))
			{
				// Has this diamond been picked before?
				if (getFDDiamondPickSeq(diamond) == 0)
				{
					// The state will change, so a reply is required
					bReply = true;

					// We can pick this diamond.
					setFDDiamondPickSeq(diamond, ++pickCount);
					m_subGame->update(SGDINDX_PICK_COUNT, pickCount);

					// We are done when we have choosen all diamonds
					if (pickCount == diamondCount && active == 1)
					{
						int32 basepayoutamount;
						int32 totalmultiplier;
						int32 totalbonuspayoutamount;

						basepayoutamount = getBetPerLine() * getNumLinesBet();
						totalmultiplier = getTotalMultiplier() * (( getGameModeId() == MODE_FREE_SPIN )  ? MULTIPLIER_FREE_SPIN : 1);
						totalbonuspayoutamount = basepayoutamount * totalmultiplier;

						BonusGame* pbonusGame = addBonusGame(0, 0, basepayoutamount, totalmultiplier, totalbonuspayoutamount, 0);
						pbonusGame->addNote(NOTE_DIAMONDDELIGHT);
						if ( getGameModeId() == MODE_FREE_SPIN)
						{
							pbonusGame->addNote(NOTE_FREE_SPIN_2X);
						}

						setGameCanComplete(true);
						m_subGame->update(SGDINDX_DDELUX_ACTIVE, 0);

						m_feature->update(SGDINDX_DIAMOND1_MULTIPLIER, m_subGame->getData(SGDINDX_DIAMOND1_MULTIPLIER));
						m_feature->update(SGDINDX_DIAMOND1_PICK_SEQUENCE, m_subGame->getData(SGDINDX_DIAMOND1_PICK_SEQUENCE));
						m_feature->update(SGDINDX_DIAMOND2_MULTIPLIER, m_subGame->getData(SGDINDX_DIAMOND2_MULTIPLIER));
						m_feature->update(SGDINDX_DIAMOND2_PICK_SEQUENCE, m_subGame->getData(SGDINDX_DIAMOND2_PICK_SEQUENCE));
						m_feature->update(SGDINDX_DIAMOND3_MULTIPLIER, m_subGame->getData(SGDINDX_DIAMOND3_MULTIPLIER));
						m_feature->update(SGDINDX_DIAMOND3_PICK_SEQUENCE, m_subGame->getData(SGDINDX_DIAMOND3_PICK_SEQUENCE));
						m_feature->update(SGDINDX_DIAMOND4_MULTIPLIER, m_subGame->getData(SGDINDX_DIAMOND4_MULTIPLIER));
						m_feature->update(SGDINDX_DIAMOND4_PICK_SEQUENCE, m_subGame->getData(SGDINDX_DIAMOND4_PICK_SEQUENCE));
						m_feature->update(SGDINDX_DIAMOND5_MULTIPLIER, m_subGame->getData(SGDINDX_DIAMOND5_MULTIPLIER));
						m_feature->update(SGDINDX_DIAMOND5_PICK_SEQUENCE, m_subGame->getData(SGDINDX_DIAMOND5_PICK_SEQUENCE));
					}
				}
			}
		}
	}

	return bReply;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::resetForNewGame()
///
/// @return	 void
///
///
/// This is an override of the framework method.
/// 
////////////////////////////////////////////////////////////////////////////
void DiamondDozenGuts::resetForNewGame()
{
	SlotGuts::resetForNewGame();
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::getDiamondDelightMultiplier()
///
/// @return	 int32      1-10 to denote the multiplier one
///						white diamond symbol can award.
///
/// This helper method is used to get the multiplier for one
/// white diamond icon.
////////////////////////////////////////////////////////////////////////////
int32
DiamondDozenGuts::getDiamondDelightMultiplier()
{
	int32 i = 0;
	static uint32 spin[][2] = {
		{NOTE_WHITEDIAMOND_1X,0},
		{NOTE_WHITEDIAMOND_2X,49},
		{NOTE_WHITEDIAMOND_3X,86},
		{NOTE_WHITEDIAMOND_4X,90},
		{NOTE_WHITEDIAMOND_5X,93},
		{NOTE_WHITEDIAMOND_6X,95},
		{NOTE_WHITEDIAMOND_7X,96},
		{NOTE_WHITEDIAMOND_8X,97},
		{NOTE_WHITEDIAMOND_9X,98},
		{NOTE_WHITEDIAMOND_10X,99},
	};

	uint32 randomValue = getRandomLessThan(100);

	while (randomValue > spin[i][1])
	{
		++i;
	}
	return spin[i][0];
}

void
DiamondDozenGuts::InitDiamondDelight()
{
    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND1, true);
    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND2, true);
    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND3, true);
    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND4, true);
    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND5, true);

	m_subGame->update(SGDINDX_SVRDIAMOND1,0);
    m_subGame->update(SGDINDX_SVRDIAMOND2,0);
    m_subGame->update(SGDINDX_SVRDIAMOND3,0);
    m_subGame->update(SGDINDX_SVRDIAMOND4,0);
    m_subGame->update(SGDINDX_SVRDIAMOND5,0);


    m_subGame->update(SGDINDX_DIAMOND_COUNT,0);
    m_subGame->update(SGDINDX_PICK_COUNT,0);
    m_subGame->update(SGDINDX_DIAMOND_MASK,0);
    m_subGame->update(SGDINDX_DIAMOND1_MULTIPLIER,0);
    m_subGame->update(SGDINDX_DIAMOND1_PICK_SEQUENCE,0);
    m_subGame->update(SGDINDX_DIAMOND2_MULTIPLIER,0);
    m_subGame->update(SGDINDX_DIAMOND2_PICK_SEQUENCE,0);
    m_subGame->update(SGDINDX_DIAMOND3_MULTIPLIER,0);
    m_subGame->update(SGDINDX_DIAMOND3_PICK_SEQUENCE,0);
    m_subGame->update(SGDINDX_DIAMOND4_MULTIPLIER,0);
    m_subGame->update(SGDINDX_DIAMOND4_PICK_SEQUENCE,0);
    m_subGame->update(SGDINDX_DIAMOND5_MULTIPLIER,0);
    m_subGame->update(SGDINDX_DIAMOND5_PICK_SEQUENCE,0);
    m_subGame->update(SGDINDX_DDELUX_ACTIVE,0);
}

int32
DiamondDozenGuts::getFDDiamondMultiplier(int32 diamond)
{
	int32 value = -1;

	if ((diamond >= 0) && (diamond < 5))
	{
		value = m_subGame->getData(SGDINDX_DIAMOND1_MULTIPLIER + (2*diamond));
	}
	return value;
}

int32
DiamondDozenGuts::getFDDiamondPickSeq(int32 diamond)
{ 
	int32 value = -1;

	if ((diamond >= 0) && (diamond < 5))
	{
		int32 multiplier = m_subGame->getData(SGDINDX_SVRDIAMOND1 + diamond);
		m_subGame->update(SGDINDX_DIAMOND1_MULTIPLIER + (2*diamond), multiplier);
		value = m_subGame->getData(SGDINDX_DIAMOND1_PICK_SEQUENCE + (2*diamond));
	}
	else
	{
		ASSERT(0);
	}
	return value;
}

bool8
DiamondDozenGuts::setFDDiamondMultiplier(int32 diamond, int32 multiplier)
{
	bool8 success = false;
	if ((diamond >= 0) && (diamond < 5) && (multiplier >= NOTE_WHITEDIAMOND_1X) && (multiplier <= NOTE_WHITEDIAMOND_10X))
	{
	    m_subGame->setServerOnly(SGDINDX_SVRDIAMOND1+diamond,true);
	    m_subGame->update(SGDINDX_SVRDIAMOND1+diamond,multiplier);
		success = true;
	}
	else
	{
		ASSERT(0);
	}
	return success;
}

bool8
DiamondDozenGuts::setFDDiamondPickSeq(int32 diamond, int32 picSeq)
{
	bool8 success = false;
	if ((diamond >= 0) && (diamond < 5) && (picSeq > 0) && (picSeq <= 5))
	{
		int32 multiplier;
		m_subGame->update(SGDINDX_DIAMOND1_PICK_SEQUENCE + (2*diamond), picSeq);

		multiplier = m_subGame->getData(SGDINDX_SVRDIAMOND1 + diamond);
		if (multiplier == 0)
		{
			ASSERT(0);
		}
		m_subGame->update(SGDINDX_DIAMOND1_MULTIPLIER + (2*diamond), multiplier);

		success = true;
	}
	else
	{
		ASSERT(0);
	}
	return success;
}

int32
DiamondDozenGuts::getTotalMultiplier()
{
	int32 multiplier = 1;
	for (int32 i=0; i<5; ++i)
	{
		int32 value = getFDDiamondMultiplier(i);
		if (value > 0)
		{

			int32 diamonmultiplier = 1;
			switch (value)
			{
				case NOTE_WHITEDIAMOND_1X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_1X;
					break;
				case NOTE_WHITEDIAMOND_2X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_2X;
					break;
				case NOTE_WHITEDIAMOND_3X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_3X;
					break;
				case NOTE_WHITEDIAMOND_4X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_4X;
					break;
				case NOTE_WHITEDIAMOND_5X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_5X;
					break;
				case NOTE_WHITEDIAMOND_6X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_6X;
					break;
				case NOTE_WHITEDIAMOND_7X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_7X;
					break;
				case NOTE_WHITEDIAMOND_8X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_8X;
					break;
				case NOTE_WHITEDIAMOND_9X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_9X;
					break;
				case NOTE_WHITEDIAMOND_10X:
					diamonmultiplier = MULTIPLIER_WHITEDIAMOND_10X;
					break;
			};
			multiplier *= diamonmultiplier;
		}
	}
	return multiplier;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::getBonusGameState() const
///
/// @param   int32   The bonus game state (active/inactive).
///
/// This is a framework override to determine the bonus game state.
////////////////////////////////////////////////////////////////////////////
int32 
DiamondDozenGuts::getBonusGameState() const
{
    return m_subGame->getData(SGDINDX_DDELUX_ACTIVE);
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::setBonusGameState( int32 bonusGameState )
///
/// @param   bonusGameState   The bonus game state (active/inactive).
///
/// This is a framework override to set the bonus game state.
////////////////////////////////////////////////////////////////////////////
void 
DiamondDozenGuts::setBonusGameState( int32 bonusGameState )
{
    m_subGame->update(SGDINDX_DDELUX_ACTIVE,bonusGameState);
} 


////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Debugging code
//
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
/// @fn 	 DiamondDozenGuts::preSpinClassifyResults()
///
/// @param   spin       Pointer to the spin with stop data.
///
/// This method is overridden in debug spins mode to alter the reel stops.
////////////////////////////////////////////////////////////////////////////
void DiamondDozenGuts::preSpinClassifyResults( SlotSpin* spin )
{
	InitDiamondDelight();

	SlotGuts::preSpinClassifyResults(spin);
	return;
}